#ifndef FIRSTMAIN_H
#define FIRSTMAIN_H

#include "config.h"
#include "edititem.h"
#include "gregion.h"
#include "ui_guimaincase.h"
#include "tabellaicone.h"
#include "dlgattributi.h"

#include "appini.h"

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QSpacerItem>
#include <QtGui/QTableView>
#include <QtGui/QWidget>

class DigitalClock : public QLCDNumber
{
    Q_OBJECT

public:
    DigitalClock(QWidget *parent = 0) {
    setSegmentStyle(Filled); 
    setSegmentStyle ( QLCDNumber::Flat );
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
    timer->start(1000);
    showTime();
    }

private slots:
void showTime()
{
    QTime time = QTime::currentTime();
    QString text = time.toString("HH:mm");
    if ((time.second() % 2) == 0) {
        text[2] = '.';
        ////text[5] = '.';
    }
    display(text);
}
};





class WebCateList : public QTreeView
{
     Q_OBJECT
//
public:
WebCateList( QWidget * parent = 0 );
void SetDb( DB_Manager * dbin );
inline QSqlQueryModel *AllowedID() { return  c_model; }
protected:
  DB_Manager *db;
  QStringList Small_Language;
  QStringList UPDA_regione;
  QStringList Long_Language;
  bool Disponi2( int tipo , int paese );
  bool Disponi( int tipo );
  void contextMenuEvent ( QContextMenuEvent * e );
  void NomiPaesi( QStandardItem *parent , int tipo , int madre , QMap<QString,QDomElement> append );
private:
   QMap<QString,QDomElement> bases;
   QMap<QString,QDomElement> topul;
   QMap<QString,QDomElement> topul2;
   QMap<QString,QDomDocument> menu;
   QSettings setter;
   QSqlQueryModel *c_model;
   QSqlQueryModel *t_model;
   QStandardItemModel *model;
   QSqlQueryModel *ReadModel;
   void Case( int tipo , int paese , QStandardItem *parent , const int regione );
   QList<QStandardItem *> Compose_Type( int rowposition );  /* tipo oggetto*/
signals:
   void OpenLocalItem(uint);
public slots:
   void init();
   void ActiveTre( QModelIndex index );
   void SendonServer();
   void OpenWeb();
   void OpenLocal();
   void OpenWebPath();

};










//
class FirstMain : public QMainWindow  
{
     Q_OBJECT
//
public:
  FirstMain( QWidget * parent =  0 );
  void Setdb( DB_Manager *dbin );
  QWidget *Controller();
  DB_Manager *db;
  QWidget *Poppi;
  QWidget *Pwebbi;
  QWidget *Panel;
  QGridLayout *gridLayout;
  QGridLayout *gridLayout_0;
  QGridLayout *gridLayout_1;
  QTabWidget *tabmenu;
  QHBoxLayout *hboxLayout;
  QHBoxLayout *hboxLayout_1;
  QLabel *label_panel;
  QLabel *label_panel_1;
  QSpacerItem *spacerItem;
  QComboBox *box_panel;
  QComboBox *box_panel_1;
  QTableView *listaoggetti;
  QDockWidget *dock_search;
  QAction *actionsearch;
  QSqlQueryModel *Model_Menu;
  QToolBar *toolBarInternal;
  QWidget *Info_Menu;
  QRect winsize;
  bool LoadDBS;
  
  WebCateList *webtree;
  
  DigitalClock *clocke;
  QLabel *statuslabel;
  QLabel *statuslabel2;
  QSettings setter;
  
private:
signals:

public slots:
  void MenuControllerSwaper();
   /////////void on_box_panel_currentIndexChanged();
   ///////////void on_paesi_currentIndexChanged();

};
//
#endif // FIRSTMAIN_H

